package vn.easyticket.db;

import java.util.HashMap;
import java.util.Map;

import vn.easyticket.db.exceptions.NoServiceFoundException;
import vn.easyticket.db.facet.AbstractReposityService;
import vn.easyticket.db.facet.C001_CountryRepositoryService;
import vn.easyticket.db.facet.C002_CityRepositoryService;
import vn.easyticket.db.facet.M001_UserProfileRepositoryService;
import vn.easyticket.db.facet.M051_WebMembershipRepositoryService;
import vn.easyticket.db.facet.M061_WebRolesRepositoryService;
import vn.easyticket.db.facet.M062_WebUserInRolesRepositoryService;

public class ServiceNameUtil
{
    public static final String C002_CITY_REPOSITY_SERVICE＿NAMED = "C002_RepositoryService";

    public static final String C001_COUNTRY_REPOSITY_SERVICE＿NAMED = "C001_RepositoryService";

    public static final String M001_USER_PROFILE_REPOSITY_SERVICE_NAMED = "M001_RepositoryService";

    public static final String M051_WEB_MEMBERSHIP_REPOSITY_SERVICE_NAMED = "M051_RepositoryService";

    public static final String M061_WEB_ROLES_REPOSITY_SERVICE_NAMED = "M061_RepositoryService";

    public static final String M062_WEB_USER_IN_ROLES_REPOSITY_SERVICE_NAMED = "M062_RepositoryService";

    private static final Map<Class<?>, String> NAMED_MAP = new HashMap<Class<?>, String>()
    {
        private static final long serialVersionUID = -8200774767886902079L;

        {
            put( C002_CityRepositoryService.class, ServiceNameUtil.C002_CITY_REPOSITY_SERVICE＿NAMED );
            put( C001_CountryRepositoryService.class, ServiceNameUtil.C001_COUNTRY_REPOSITY_SERVICE＿NAMED );
            put( M001_UserProfileRepositoryService.class, ServiceNameUtil.M001_USER_PROFILE_REPOSITY_SERVICE_NAMED );
            put( M051_WebMembershipRepositoryService.class, ServiceNameUtil.M051_WEB_MEMBERSHIP_REPOSITY_SERVICE_NAMED );
            put( M062_WebUserInRolesRepositoryService.class, ServiceNameUtil.M062_WEB_USER_IN_ROLES_REPOSITY_SERVICE_NAMED );
            put( M061_WebRolesRepositoryService.class, ServiceNameUtil.M061_WEB_ROLES_REPOSITY_SERVICE_NAMED );
        }
    };

    public static <T extends AbstractReposityService<?, ?>> String getServiceName( Class<T> service )
        throws NoServiceFoundException
    {
        String name = "";
        try
        {
            name = NAMED_MAP.get( service );
        }
        catch ( Exception ex )
        {
            throw new NoServiceFoundException();
        }
        return name;
    }

}
